package edu.whut.mall.portal.enums;

import edu.whut.mall.common.exception.MallException;

/**
 * @program: d9lab-mall
 * @description: 团购参与者种类
 * @author: Wayne
 * @create: 2020-05-18 15:38
 **/
public enum GroupBuyUserTypeEnum {
    GROUP_BUY_CREATE(0,"发起者"),GROUP_BUY_JOIN(1,"参与者");
    private Integer code;
    private String desc;

    GroupBuyUserTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static GroupBuyUserTypeEnum getGroupBuyUserTypeByCode(Integer code){
        for (GroupBuyUserTypeEnum type: GroupBuyUserTypeEnum.values()) {
            if (type.getCode().equals(code)){
                return type;
            }
        }
        throw new MallException("传入用户类型不对");
    }
}
